<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <style type="text/css">
        .person-list {
            max-height: 600px;
            overflow-y: scroll;
            height: 300px;
        }
    </style>
</head>
<body>
<div class="tplay-body-div">
    <div style="margin-top: 20px;">
    </div>
    <form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">人员</label>
        <div class="layui-collapse layui-input-inline person-list" lay-accordion="">
            {volist name="presonRoleList" id="presonRole"}
            <div class="layui-colla-item" style="">
                <h2 class="layui-colla-title" style="background:0;">{$presonRole.name}</h2>
                <div class="layui-colla-content">
                    <table>
                        <tbody>
                        {volist name="presonRole.person_list" id="person"}
                        <tr>
                            <td>
                                <input type="checkbox" lay-verify="otherReq"  class="otherReq personId" lay-ignore lay-skin="primary" name="personId[]" value="{$person.admin_id}" <?php echo in_array($person['admin_id'], $personIds)?'checked="checked"':'' ?> > {$person.admin_name}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
            {/volist}
        </div>
    </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="transmit">确定</button>
                <button class="layui-btn" id="closeIframe">关闭</button>
            </div>
        </div>
    </form>
</div>

{include file="public/foot"}

<script type="application/javascript">
    var index = parent.layer.getFrameIndex(window.name);
    //关闭iframe
    $('#closeIframe').click(function(){
        parent.layer.close(index);
    })
    $('#transmit').click(function () {
        let personIdArr = [];
        $('.personId').each(function (index,item){
            if($(item).is(':checked')){
                console.info($(item).val());
                personIdArr.push($(item).val())
            }
        })
        parent.$('#person_ids').val(personIdArr.toString());
        parent.layer.close(index);

    })

    $(function(){
        var str = parent.$('#person_ids').val();
        var arr = str.split(',');
        $('.personId').each(function (index,item){
            if(arr.indexOf($(item).val()) != -1 ){
                $(item).prop("checked",true);
            }
        })
    })
</script>
    </body>
</html>